package com.yunwuliu.eunm;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 16375
 * @version 1.0
 * @description: TODO
 * @date 2025/7/22 12:20
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {

    private Integer code;
    private String msg;
    private T data;

    public static <T> Result<T> success(T data) {
        return new Result<>(ResultEnum.SUCCESS.getCode(),ResultEnum.SUCCESS.getMsg(),data);
    }
    public static <T> Result<T> success(String msg,T data) {
        return new Result<>(ResultEnum.SUCCESS.getCode(),msg,data);
    }
    public static <T> Result<T> fail(T data) {
        return new Result<>(ResultEnum.COMMON_ERROR.getCode(),ResultEnum.COMMON_ERROR.getMsg(),data);
    }
    public static <T> Result<T> fail(String msg,T data) {
        return new Result<>(ResultEnum.COMMON_ERROR.getCode(),msg,data);
    }
}
